#!/bin/sh
#######################################################################
# Begin swat
#
# Description : Start samba server
#
# Author      : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version     : BLFS 7.0
#
########################################################################

### BEGIN INIT INFO
# Provides:            swat
# Required-Start:      $network
# Should-Start:        networkmanager samaba wicd
# Required-Stop:       $network
# Should-Stop:         networkmanager samba wicd
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   Provides Samba configuration tool
# Description:         Starts Samba configuration tool over a secure 
#                      tunnel;
# X-LFS-Provided-By:   BLFS
### END INIT INFO

. /lib/lsb/init-functions

#$LastChangedBy: dj $
#$Date: 2019-09-08 13:50:13 -0500 (Sun, 08 Sep 2019) $

config=/etc/stunnel/swat.conf

if [ ! -r /etc/stunnel/swat.conf ]; then
   log_failure_msg "swat configuration file missing: $config"
   exit 1
fi

# Pid coordinates with /etc/stunnel/swat.conf
pidfile=/run/stunnel-swat.pid 

case "$1" in
   start)
      log_info_msg "Starting swat..."
      start_daemon /usr/bin/stunnel $config
      evaluate_retval
      ;;

   stop)
      log_info_msg "Stopping swat..."
      killproc -p $pidfile /usr/bin/stunnel
      evaluate_retval
      ;;

   restart)
      $0 stop
      sleep 1
      $0 start
      ;;

   status)
      statusproc -p $pidfile /usr/bin/stunnel
      ;;

   *)
      echo "Usage: $0 {start|stop|restart|status}"
      exit 1
      ;;
esac

# End /etc/init.d/samba
